//纯函数与不纯函数  slice  /  splice
let array = [1, 2, 3, 4, 5];

//纯函数
//slice(起始位置，终止位置)  *不包括终止位置的元素
console.log(array.slice(0, 3));     //[1, 2, 3]
console.log(array.slice(0, 3));     //[1, 2, 3]
console.log(array.slice(0, 3));     //[1, 2, 3]

//不纯函数
//splice(起始位置，选取个数)  
console.log(array.splice(0, 3));     //[1, 2, 3]
console.log(array.splice(0, 3));     //[4, 5]
console.log(array.splice(0, 3));     //[]

//纯函数
function getSum (n1, n2) {
    return n1 + n2;
}

console.log(getSum(1, 2));     //3
console.log(getSum(1, 2));     //3
console.log(getSum(1, 2));     //3